#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+10;
const double ex=0.0000001;
int t,n,m;
double V;
double L;
double d[N],v[N],a[N];
struct hbr{
    double l,r;
    int fl,ln,rn;
}h[N],o[N];
double p[N];
int cmp(hbr a,hbr b){
    return (a.ln==b.ln)?a.rn>b.rn:a.ln>b.ln;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            h[i].fl=0;
            h[i].l=0;
            h[i].r=0;
            if(a[i]<0){
                if(v[i]<=V)h[i].fl=1;
                else{
                    h[i].l=d[i];
                    h[i].r=(V*V-v[i]*v[i])*1.0/(2*a[i])+d[i]-ex;
                    h[i].r=min(h[i].r,L);
                }
            }else if(a[i]==0){
                if(v[i]<=V)h[i].fl=1;
                else{
                    h[i].l=d[i];
                    h[i].r=L;
                }
            }else{
                if(v[i]>V){
                    h[i].l=d[i];
                    h[i].r=L;
                }else{
                    h[i].l=(V*V-v[i]*v[i])*1.0/(2*a[i])+d[i]+ex;
                    h[i].r=L;
                    if(h[i].l>L)h[i].fl=1;
                }
            }
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        int cnt=0;
        for(int i=1;i<=n;i++){
            h[i].ln=lower_bound(p+1,p+1+m,h[i].l)-p;
            h[i].rn=upper_bound(p+1,p+1+m,h[i].r)-p-1;
            if(h[i].ln>h[i].rn)h[i].fl=1;
            if(!h[i].fl){
                //cout<<i<<'\n';
                o[++cnt]=h[i];
            }
        }
        cout<<cnt<<' ';
        sort(o+1,o+1+cnt,cmp);
        int lm=m+1,ans=0;
        for(int i=1;i<=cnt;i++){
            if(lm>o[i].rn){
                ans++;
                lm=o[i].ln;
            }
        }
        cout<<m-ans<<'\n';
    }
    return 0;
}
